const defaultState = {
    visible: false,
    loading: false,
    dataSource: []

};
export default function createLinePriceInCreateModal(state = defaultState, action) {
    const {type, payload} = action;
    switch (type) {
        case 'CLIENT.IMPORT_LINE_IN_CREATE_MODAL':
            const historyDataList = state.dataSource;
            if (payload) {
                payload.forEach(item => {
                    item.id = Math.random();
                    item.startDate = item.startDate.substring(0, 10);
                    item.endDate = item.endDate.substring(0, 10);
                    historyDataList.push(item);
                });
            }
            return {...state, dataSource: [...historyDataList]};
        case 'CLIENT.UPDATE_LINE_PRICE_IN_CREATE_MODEL':
            return {...state, dataSource: [...payload]};
        case 'CLIENT.ADD_LINE_PRICE_IN_CREATE_MODEL':
            const historyDataList2 = state.dataSource;
            payload.id = Math.random();
            historyDataList2.push({...payload});
            return {...state, dataSource: [...historyDataList2]};
        default:
            return state;
    }
}

